package com.jlpay.openapi.demo.trans.common;

import com.jlpay.open.jlpay.sdk.java.model.trans.common.request.GetOpenidRequest;
import com.jlpay.open.jlpay.sdk.java.model.trans.common.response.GetOpenidResponse;
import com.jlpay.open.jlpay.sdk.java.utils.json.JsonUtils;
import com.jlpay.openapi.demo.JlpayOpenApiService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 *
 * @author dengwenning
 * @since 2024/9/23
 **/
public class GetOpenidService {
    private static final Logger LOGGER = LoggerFactory.getLogger(GetOpenidService.class);

    public static void main(String[] args) {
        GetOpenidRequest getOpenidRequest = buildGetOpenidRequest();
        GetOpenidResponse getOpenidResponse = JlpayOpenApiService.openMerchService()
                .post(getOpenidRequest, GetOpenidResponse.class);
        LOGGER.info("获取openid响应:{}", JsonUtils.toString(getOpenidResponse));
    }

    private static GetOpenidRequest buildGetOpenidRequest() {
        GetOpenidRequest getOpenidRequest = new GetOpenidRequest();

        getOpenidRequest.setMchId("849584358120018");
        getOpenidRequest.setPayType("wxpay");
        getOpenidRequest.setAuthCode("131208648101095993");
        getOpenidRequest.setSubAppid("wxd930ea53421a258f4f");
//        getOpenidRequest.setAppUpIdentifier("UnionPay/1.0");

        return getOpenidRequest;
    }
}
